package com.quectel.sys.module.sys.entity.mongo;

import com.quectel.constant.BackupConfigConstants;
import com.quectel.sys.constants.MongoCollectionConstants;
import com.quectel.util.client.mongo.MongoBaseModel;
import lombok.Data;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

/**
 * 系统日志
 *
 * @author caolu
 * @email louis.cao@quectel.com
 */
@Data
@Document(MongoCollectionConstants.SYS_LOG_COLLECTION)
public class SysLogModel implements MongoBaseModel {
    private Long id;

    /**
     * 租户id
     */
    @Indexed(name = "idx_tenant_id", background = true)
    private Long tenantId;
    /**
     * 账号
     */
    @Indexed(name = "idx_account", background = true)
    private String account;
    /**
     * 用户名
     */
    private String username;
    /**
     * 所属组名称
     */
    private String groupName;

    /**
     * 请求者ip
     */
    private String requesterIp;

    /**
     * 请求链接
     */
    private String requestUri;

    /**
     * 具体方法
     */
    private String methodString;

    /**
     * 执行时长
     */
    private Long executeDuration;

    /**
     * 具体日志
     */
    private String log;

    /**
     * 日志发生时间
     */
    @Indexed(name = "index_create_time", background = true, expireAfterSeconds = BackupConfigConstants.MONGO_LOG_DATA_DEFAULT_RETAIN_SECONDS)
    private Date createTime;
}
